package handler

import (
	"doctor2/model"
	"github.com/gin-gonic/gin"
)

func Create(c *gin.Context) {
	name := c.PostForm("name")
	address := c.PostForm("address")
	data := model.Doctor{
		Name:    name,
		Address: address,
	}
	model.DB.Create(&data)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
func List(c *gin.Context) {

	var data []model.Doctor
	model.DB.Debug().Find(&data)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "查询成功",
		"data": data,
	})
	return
}
func Detail(c *gin.Context) {
	id := c.Query("id")
	var data model.Doctor

	model.DB.Model(&model.Doctor{}).Where("id=?", id).First(&data)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "查询成功",
		"data": data,
	})
	return
}
